<?php
require_once ('../libs/Smarty.class.php');

$smarty = new Smarty ();

//$smarty->force_compile = true;
$smarty->debugging = true;
$smarty->caching = false;
//$smarty->cache_lifetime = 120;
require_once '../util/auth.php';
if (isLoggedIn ()) {
	if(isset($_POST['t'])) $tid = $_POST['t'];
	elseif(isset($_GET ["t"]))$tid = $_GET ["t"];
	else{
		// No tid given
		die ( 'No tid(?t=%d) given' );
	}
	// tid given
	$smarty->assign("username", $_SESSION["username"]);
	
	$path = sprintf('test_logic/t%s.php', $tid);
	if(!file_exists($path)) die('This test cannot be found.');
	require_once $path;
	displayTestPage($smarty, $_POST);
} else {
	header ( 'Location: /cpanel/login.php' );
}

